﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using IBatisNet.DataMapper;
using TumbaloSoft.Helpers.QueryObjects;
using TumbaloSoft.Models;

namespace TumbaloSoft.Helpers
{
    public class HelperBoleta
    {
        public static int insert(TumbaloSoft.Models.Boleta boleta)
        {
            Mapper.Instance().Insert("BoletaInsert", boleta);
            return 0;
        }
        public static void update(TumbaloSoft.Models.Boleta boleta)
        {
            Mapper.Instance().Update("BoletaUpdate", boleta);
        }
    
        public static IList selectAll()
        {
            return Mapper.Instance().QueryForList("BoletaSelectAll", null);       
        }
        public static int selectMaxCodigo()
        {
            return (int)Mapper.Instance().QueryForObject("BoletaSelectMaxCodigo", null);
        }


        static public int SiguienteCodigo()
        {
            return (int)Mapper.Instance().QueryForObject("BoletaSiguienteCodigo", null);
        }

        static public Boleta selectById(int id)
        {
            IList boletas = Mapper.Instance().QueryForList("BoletaSelectById", id);
            if (boletas.Count == 0) return null;
            Boleta boleta= (Boleta)(boletas[0]);
            return boleta;
        }
       
    }
}